package day12;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author Xiao
 * @date 2021/8/3
 */
public class ByteStreamDemo01 {
    /**
     *      需求：字节流拷贝文件
     */
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("classpractice\\src\\day12\\demo01.txt");
        FileOutputStream fos = new FileOutputStream("classpractice\\src\\day12\\demo01Copy.txt");
//        transByte(fis, fos);
        byte[] bytes = new byte[3];
        int len;
        while ((len = fis.read(bytes)) != -1) {
            fos.write(bytes,0,len);
        }
        fis.close();
        fos.close();
    }

    private static void transByte(FileInputStream fis, FileOutputStream fos) throws IOException {
        int read;
        while ((read = fis.read()) != -1) {
            fos.write(read);
        }
    }
}
